home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CBASE102.ARJ / BCLOSEAL.C < prev    next >
Text File  |  1991-09-23  |  1KB  |  58 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "@(#)bcloseal.c    1.5 - 91/09/23" */
  5.  
  6. #include <ansi.h>
  7.  
  8. /* ansi headers */
  9. #ifdef AC_STDDEF
  10. #include <stddef.h>
  11. #endif
  12.  
  13. /* local headers */
  14. #include "blkio_.h"
  15.  
  16. /*man---------------------------------------------------------------------------
  17. NAME
  18.      bcloseall - close all block files
  19.  
  20. SYNOPSIS
  21.      #include <blkio.h>
  22.  
  23.      void bcloseall()
  24.  
  25. DESCRIPTION
  26.      The bcloseall function closes all open block files, flushing the
  27.      buffers.  Any program using the blkio library should register
  28.      bcloseall, with the ANSI C function atexit, to be called
  29.      automatically on termination.  This will prevent the loss of
  30.      buffered data that has not yet been written to the file.
  31.  
  32.      If the atexit function is not available, bexit should be used
  33.      everywhere in place of exit.
  34.  
  35. SEE ALSO
  36.      bclose, bexit.
  37.  
  38. ------------------------------------------------------------------------------*/
  39. #ifdef AC_PROTO
  40. void bcloseall(void)
  41. #else
  42. void bcloseall()
  43. #endif
  44. {
  45.     BLKFILE *bp = NULL;
  46.  
  47.     /* close all open block files */
  48.     for (bp = biob; bp < (biob + BOPEN_MAX); ++bp) {
  49.         if (bp->flags & BIOOPEN) {
  50.             if (bclose(bp) == -1) {
  51.                 BEPRINT;
  52.             }
  53.         }
  54.     }
  55.  
  56.     return;
  57. }
  58.